package com.atguigu.springcloud.controller;

import com.atguigu.springcloud.entites.JsonResult;
import com.atguigu.springcloud.entites.Payment;
import com.atguigu.springcloud.service.IPaymentFeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName OrderFeignController
 * @Author VCR
 * @Date 2021/12/25 20:12
 * @Version 1.0
 */
@RestController
public class OrderFeignController {

    @Autowired
    private IPaymentFeignService paymentFeignService;

    @GetMapping("/consumer/payment/get/{id}")    // 消费者调
    public JsonResult<Payment> getPaymentId(@PathVariable("id") Long id) {
        return paymentFeignService.queryPaymentById(id);
    }

    @GetMapping("/consumer/payment/feign/timeout")
    public String paymentFeignTimeout() {
        /**
         * OpenFeign-ribbon,客户端默认等待1秒
         * 这里故意超时报错
         */
        return paymentFeignService.paymentFeignTimeout();
    }
}
